/**
 * 
 */
package com.qolome.utils.web;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.validation.ObjectError;

import com.google.common.base.Joiner;
import com.qolome.enums.ResultEnum;

/**
 * @Description: 错误返回封装
 * @author 姜锋
 * @date 2020年1月5日 下午4:15:59 
 * @version V1.0   
 *
 */
public class ErrReturnUtils {
	
	public static  <T>HttpResult<T> returnError (List<ObjectError> list) {
		Joiner joiner = Joiner.on(",").skipNulls();
		return HttpResult.exception(ResultEnum.ERROR_BEAN, joiner.join(
				list.stream().map(e -> e.getDefaultMessage()).collect(Collectors.toList())),
				null);
		
	}
}
